# $Id$
# Maintainer: Angel Velasquez <angvp@archlinux.org>
# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgbase=python-astroid
pkgname=('python2-astroid' 'python-astroid')
pkgver=1.5.3
pkgrel=1
pkgdesc="Useful miscellaneous modules used by Logilab projects"
arch=('any')
url="https://github.com/PyCQA/astroid"
license=('LGPL')
makedepends=('python-setuptools' 'python2-setuptools' 'python-six' 'python2-six'
             'python-lazy-object-proxy' 'python2-lazy-object-proxy' 'python-wrapt' 'python2-wrapt'
             'python2-singledispatch' 'python2-enum34' 'python2-backports.functools_lru_cache')
checkdepends=('python-dateutil' 'python2-dateutil' 'python-pytest' 'python2-pytest' 'python-numpy'
              'python2-numpy' 'python-nose' 'python2-nose')
source=("$pkgbase-$pkgver.tar.gz::https://github.com/PyCQA/astroid/archive/astroid-$pkgver.tar.gz")
sha512sums=('dc475fbd11960584862f8c6e4f505114f70e9551c8bfb5a8d7061b268cb3313bf4d6fc59c46eca1ff12fcbf436c9c512b9bdebc7441a56265b16c830802b7423')

prepare() {
  cp -a astroid-astroid-$pkgver{,-py2}
}

build() {
  cd "$srcdir"/astroid-astroid-$pkgver
  python setup.py build

  cd "$srcdir"/astroid-astroid-$pkgver-py2
  python2 setup.py build
}

check() {
  cd "$srcdir"/astroid-astroid-$pkgver
  PYTHONPATH="$PWD/build/lib:$PYTHONPATH" python -Wi -m unittest discover -s build/lib/astroid/tests -p "unittest*.py"

  cd "$srcdir"/astroid-astroid-$pkgver-py2
  PYTHONPATH="$PWD/build/lib:$PYTHONPATH" python2 -Wi -m unittest discover -s build/lib/astroid/tests -p "unittest*.py"
}

package_python-astroid() {
  depends=('python-six' 'python-lazy-object-proxy' 'python-wrapt')
  replaces=('python-logilab-astng')
  conflicts=('python-logilab-astng')

  cd astroid-astroid-$pkgver

  python setup.py install --optimize=1 --skip-build --prefix=/usr --root="$pkgdir"
}

package_python2-astroid() {
  depends=('python2-six' 'python2-lazy-object-proxy' 'python2-wrapt' 'python2-singledispatch'
           'python2-enum34' 'python2-backports.functools_lru_cache')
  replaces=('python2-logilab-astng')
  conflicts=('python2-logilab-astng')

  cd astroid-astroid-$pkgver-py2

  python2 setup.py install --optimize=1 --skip-build --prefix=/usr --root="$pkgdir"
}
